import 'package:lx_widgets_library/extension/enum_ex.dart';

// 信号等级
enum SignalLevelType {
  // 无
  warning(-1, "Gear_none"),

  // 0格信号
  gear_0(0, "Gear_0"),

  // 1格信号
  gear_1(1, "Gear_1"),

  // 2格信号
  gear_2(2, "Gear_2"),

  // 3格信号
  gear_3(3, "Gear_3"),

  // 4格信号
  gear_4(4, "Gear_4");

  final int rawValue;
  final String name;
  const SignalLevelType(this.rawValue, this.name);
  // 通过 title 获取枚举类型
  static SignalLevelType? getTypeByTitle(String title) => SignalLevelType.values
      .firstWhereOrNull((activity) => activity.name == title);
  // 通过 rawValue 获取枚举类型
  static SignalLevelType? getTypeByNum(int rawValue) => SignalLevelType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue);
  // 通过 rawValue 获取 title
  static String? getValue(int rawValue) => SignalLevelType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue)
      ?.name;
}

// 云盒状态类型
enum CloudBoxHmicStateType {
  // 无云盒
  none(-1, "None"),

  // 云盒离线
  offline(0, "Offline"),

  // 云盒在线
  online(1, "Online");

  final int rawValue;
  final String name;
  const CloudBoxHmicStateType(this.rawValue, this.name);
  // 通过 title 获取枚举类型
  static CloudBoxHmicStateType? getTypeByTitle(String title) =>
      CloudBoxHmicStateType.values
          .firstWhereOrNull((activity) => activity.name == title);
  // 通过 rawValue 获取枚举类型
  static CloudBoxHmicStateType? getTypeByNum(int rawValue) =>
      CloudBoxHmicStateType.values
          .firstWhereOrNull((activity) => activity.rawValue == rawValue);
  // 通过 rawValue 获取 title
  static String? getValue(int rawValue) => CloudBoxHmicStateType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue)
      ?.name;
}
